import axios from 'axios';
import utils from './utils';

const service = axios.create({ withCredentials: true });

const isGa = () => {
  return utils.getCookie('version') === 'ga';
};

const dingdingUrl = () => {
  return isGa() ? 'ga-dingding-devops.aliyun.com' : 'dingding-devops.aliyun.com';
};

const loginAppId = () => {
  return isGa() ? 'dingoaazjb537qmvxp4m1k' : 'dingoacy4jj3i2bba6z2we';
};

const dingdingGet = (path) => {
  return service.get(`https://${dingdingUrl()}${path}`);
};

const dingdingPost = (path) => {
  return service.post(`https://${dingdingUrl()}${path}`);
};

export { dingdingUrl, loginAppId, dingdingGet, dingdingPost };
